import 'package:guochaoapp/model/mallinit_entity.dart';

mallinitEntityFromJson(MallinitEntity data, Map<String, dynamic> json) {
	if (json['success'] != null) {
		data.success = json['success'];
	}
	if (json['msg'] != null) {
		data.msg = json['msg'].toString();
	}
	if (json['code'] != null) {
		data.code = json['code'] is String
				? int.tryParse(json['code'])
				: json['code'].toInt();
	}
	if (json['data'] != null) {
		data.data = new List<MallinitData>();
		(json['data'] as List).forEach((v) {
			data.data.add(new MallinitData().fromJson(v));
		});
	}
	if (json['sign'] != null) {
		data.sign = json['sign'];
	}
	return data;
}

Map<String, dynamic> mallinitEntityToJson(MallinitEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['success'] = entity.success;
	data['msg'] = entity.msg;
	data['code'] = entity.code;
	if (entity.data != null) {
		data['data'] =  entity.data.map((v) => v.toJson()).toList();
	}
	data['sign'] = entity.sign;
	return data;
}

mallinitDataFromJson(MallinitData data, Map<String, dynamic> json) {
	if (json['categoryId'] != null) {
		data.categoryId = json['categoryId'] is String
				? int.tryParse(json['categoryId'])
				: json['categoryId'].toInt();
	}
	if (json['categoryName'] != null) {
		data.categoryName = json['categoryName'].toString();
	}
	if (json['img'] != null) {
		data.img = json['img'].toString();
	}
	if (json['categoryList'] != null) {
		data.categoryList = new List<MallinitDataCategoryList>();
		(json['categoryList'] as List).forEach((v) {
			data.categoryList.add(new MallinitDataCategoryList().fromJson(v));
		});
	}
	if (json['brandList'] != null) {
		data.brandList = new List<MallinitDataBrandList>();
		(json['brandList'] as List).forEach((v) {
			data.brandList.add(new MallinitDataBrandList().fromJson(v));
		});
	}
	return data;
}

Map<String, dynamic> mallinitDataToJson(MallinitData entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['categoryId'] = entity.categoryId;
	data['categoryName'] = entity.categoryName;
	data['img'] = entity.img;
	if (entity.categoryList != null) {
		data['categoryList'] =  entity.categoryList.map((v) => v.toJson()).toList();
	}
	if (entity.brandList != null) {
		data['brandList'] =  entity.brandList.map((v) => v.toJson()).toList();
	}
	return data;
}

mallinitDataCategoryListFromJson(MallinitDataCategoryList data, Map<String, dynamic> json) {
	if (json['categoryId'] != null) {
		data.categoryId = json['categoryId'] is String
				? int.tryParse(json['categoryId'])
				: json['categoryId'].toInt();
	}
	if (json['categoryName'] != null) {
		data.categoryName = json['categoryName'].toString();
	}
	if (json['img'] != null) {
		data.img = json['img'];
	}
	if (json['children'] != null) {
		data.children = json['children'];
	}
	return data;
}

Map<String, dynamic> mallinitDataCategoryListToJson(MallinitDataCategoryList entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['categoryId'] = entity.categoryId;
	data['categoryName'] = entity.categoryName;
	data['img'] = entity.img;
	data['children'] = entity.children;
	return data;
}

mallinitDataBrandListFromJson(MallinitDataBrandList data, Map<String, dynamic> json) {
	if (json['brandId'] != null) {
		data.brandId = json['brandId'] is String
				? int.tryParse(json['brandId'])
				: json['brandId'].toInt();
	}
	if (json['brandName'] != null) {
		data.brandName = json['brandName'].toString();
	}
	if (json['logo'] != null) {
		data.logo = json['logo'].toString();
	}
	return data;
}

Map<String, dynamic> mallinitDataBrandListToJson(MallinitDataBrandList entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['brandId'] = entity.brandId;
	data['brandName'] = entity.brandName;
	data['logo'] = entity.logo;
	return data;
}